The present application relates generally to an improved data processing apparatus and method and more specifically to an apparatus and method for automated assertion checking with architectural support.
In computer programming, an assertion is a predicate (i.e., a true/false statement) placed in a program to indicate that the developer thinks that the predicate is always true at that place. An assertion may be used to verify that an assumption made by the programmer during the implementation of the program remains valid when the program is executed. The process of determining whether assertions remain valid during runtime is referred to as “assertion checking.” An advantage of assertion checking is that when an error occurs, it is detected immediately and directly rather than later through its often obscure side-effects. Because an assertion failure usually reports the code location, one may pin-point the error without further debugging.
Inserting assertion checking into a program can slow execution down by 10-30%, or more. If the developer forgets to remove assertion checking from the program, execution may continue to perform unnecessary assertion checking, thus resulting in poor performance. Other human error may affect assertion checking itself. For example, a developer may forget to recompute an assertion after the constituent variables change. Also, assertions could be violated silently in a language that uses undisciplined pointers (e.g., C and C++ programming languages).